/* 
 * Enterprise Library Extensions - DI + ORM.
 * Copyright (C) 2006
 *
 * GNU General Public License
 *
 * This program is free software; you can redistribute 
 * it and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 */
using System;
using ELE.Common.Util;

namespace ELE.EnterpriseLibrary.Naming
{
	/// <summary>
  /// This class represents the object name and class name pair of a binding found in a context. 
  /// A context consists of name-to-object bindings. The NameClassPair class represents the name 
  /// and the class of the bound object. It consists of a name and a string representing the 
  /// package-qualified class name. 
  /// Use subclassing for naming systems that generate contents of a name/class pair dynamically.
  /// A NameClassPair instance is not synchronized against concurrent access by multiple threads. 
  /// Threads that need to access a NameClassPair concurrently should synchronize amongst themselves 
  /// and provide the necessary locking. 
	/// </summary>
	[Serializable]
	public class NameClassPair : ClassAssemblyPair
	{
    /// <summary>
    /// Name
    /// </summary>
    protected string mName;
    /// <summary>
    /// is name relative
    /// </summary>
    protected bool mIsRelative = false;
    /// <summary>
    /// Constructs an instance of a NameClassPair given its name and class name.
    /// </summary>
    /// <param name="name">The non-null name of the object. It is relative to the target context 
    /// (which is named by the first parameter of the list() method)</param>
    /// <param name="assemblyName">The possibly null assembly name of the object bound to name. It is 
    /// null if the object bound is null</param>
    /// <param name="className">The possibly null class name of the object bound to name. It is 
    /// null if the object bound is null</param>
		public NameClassPair(string name, string className, string assemblyName): base(className, assemblyName)
		{
      Name = name;
    }
    /// <summary>
    /// Constructs an instance of a NameClassPair given its name and class name.
    /// </summary>
    /// <param name="name">The non-null name of the object. It is relative to the target context 
    /// (which is named by the first parameter of the list() method)</param>
    /// <param name="className">The possibly null class name of the object bound to name. It is 
    /// null if the object bound is null</param>
    /// <param name="assemblyName">The possibly null assembly name of the object bound to name. It is 
    /// null if the object bound is null</param>
    /// <param name="isRelative">true if name is a name relative to the target context (which is 
    /// named by the first parameter of the list() method); false if name is a URL string.</param>
    public NameClassPair(string name, string className, string assemblyName, bool isRelative): base(className, assemblyName)
    {
      Name = name;
      IsRelative = isRelative;
    }
    /// <summary>
    /// The non-null name of the object. It is relative to the target context 
    /// (which is named by the first parameter of the list() method)
    /// </summary>
    public string Name
    {
      get
      {
        return mName;
      }
      set
      {
        mName = value;
      }
    }
    /// <summary>
    /// true if name is a name relative to the target context (which is 
    /// named by the first parameter of the list() method); false if name is a URL string.
    /// </summary>
    public bool IsRelative
    {
      get
      {
        return mIsRelative;
      }
      set
      {
        mIsRelative = value;
      }
    }
    /// <summary>
    /// String rep
    /// </summary>
    /// <returns></returns>
    public override string ToString()
    {
      return mName + ":" + ClassAssemblyName;
    }
	}
}
